
** Authors: Dan Butler and Margit Tavits
** Title: "Shared Interests Foster Interethnic Cooperation Among Politicians"
** Journal: Political Science Research and Methods
** This file recreates the following from the paper:

clear
set more off

*********************
** Create Variabes **
*********************

** General Control Variables
	gen off_female=q2==2
		label var off_female "Female Respondent"
	gen off_bosniak=q1==3
		label var off_bosniak "Bosniak Respondent"
	gen off_serb=q1==1
		label var off_serb "Serb Respondent"
	gen off_croat=q1==2
		label var off_croat "Croat Respondent"
	gen off_other=q1==95

**Generate "elected officials" using q3
	generate elected =.
	replace elected = 1 if q3>0
	recode elected .=0
		label var elected "Elected Official"
		
** Experience & Region
	rename q3 tenure 
		label var tenure "Years in Office"
	
		label var RSentity "Republika Srpska"
		
** Genderate Variables for the IPA Experiment		
	egen combined_q15=rowtotal(q15_1 q15_2 q15_3 q15_4)
	gen dv_pick_partner1=combined_q15==1
	
	gen tr_partner1_coethnic=1 if q15_1!=. | q15_3!=.
		replace tr_partner1_coethnic=0 if tr_partner1_coethnic==.
	
	gen dv_pick_coethnicpartner= 1 - abs(dv_pick_partner1 - tr_partner1_coethnic)
	
	gen tr_knowpartner_pref=1 if q15_3!=. | q15_4!=.
		replace tr_knowpartner_pref=0 if tr_knowpartner_pref==.
	
** This drops the people who said "Other" for ethnicity.  	
	drop if q1==95

*************************************	
** Information Given in Footnote 8 **
** Issue Priorites and Ethnicity   **
*************************************	
** Issue: Child Care
tab q1 q4_1, row
** Issue: Education
tab q1 q4_2, row
** Issue: Maintaining Roads
tab q1 q4_3, row
** Issue: Political Participation
tab q1 q4_4, row
  
*********************************
** Table 1. IPA and Partnering ** 
*********************************
	** In the information condition, the Co-ethnic always prefers the R's least favored project.
	** Column 1	
	reg dv_pick_coethnicpartner tr_knowpartner_pref 
		** Tests if each group is different from 50% (the no bias point)
		test _cons=.5
		test _cons+ tr_knowpartner_pref=.5	
	** Column 2	
	reg dv_pick_coethnicpartner tr_knowpartner_pref if q1==3
		test _cons=.5
		test _cons+ tr_knowpartner_pref=.5
	** Column 3	
	reg dv_pick_coethnicpartner tr_knowpartner_pref if q1==2
		test _cons=.5
		test _cons+ tr_knowpartner_pref=.5
	** Column 4
	reg dv_pick_coethnicpartner tr_knowpartner_pref if q1==1
		test _cons=.5
		test _cons+ tr_knowpartner_pref=.5

	** Get the results in the Bottom of Table 1
	** Use interaction terms to compare the difference in treatments across groups
		gen serb_tr =off_serb*tr_knowpartner_pref
	** The Interaction term gives the "Serbs-Bosniaks" result at bottom of Table 1
		reg dv_pick_coethnicpartner tr_knowpartner_pref off_serb serb_tr if off_serb==1 | off_bosniak==1
	** The Interaction term gives the "Serbs-Croats" result at bottom of Table 1
		reg dv_pick_coethnicpartner tr_knowpartner_pref off_serb serb_tr if off_croat==1 | off_serb==1

	** Footnote 12: Focus on those who didn't choose political participation as their least favorite issue
		reg dv_pick_coethnicpartner tr_knowpartner_pref if q4_4!=4
	
	** Gives results from the control condition, mentioned as follows in the paper "the Croat and Serb respondents showed a stronger preference for working with a coethnic than the Bosniak respondents (73% versus 56%) indicating a higher level of baseline in-group preference."  
		table q1 tr_knowpartner_pref, c(mean dv_pick_coethnicpartner)
	
	* Table OA5, Column 1: Look at the Effect by Elected or Not
		reg dv_pick_coethnicpartner tr_knowpartner_pref##elected 
	
	
***************************
** EU Benefits and Trust ** 
***************************

** Identify the Respodents who are negative towards the EU	
	** Table OA2.1
	tabulate q6a_1

	** Table OA2.2
	gen EUdoubters=0
		replace EUdoubters=1 if q6a_1==97
		replace EUdoubters=2 if q6a_1==98
		replace EUdoubters=. if q6a_1==.
	tabulate EUdoubters q1, column
	
** Prepare Variables for analysis
	gen tr_EU_benefits=0
		replace tr_EU_benefits=1 if q6a_1!=.
						
	rename whoQ10_ethn rd1_ethn
	rename whoq10_gen rd1_gen
	rename q10 rd1_dv
	rename whoQ11_ethn rd2_ethn
	rename whoq11_gen rd2_gen
	rename q11 rd2_dv
	rename whoQ12_ethn rd3_ethn
	rename whoq12_gen rd3_gen
	rename q12 rd3_dv
	rename whoQ13_ethn rd4_ethn
	rename whoq13_gen rd4_gen
	rename q13 rd4_dv

	** Create 4 observations - 1/round
	expand 4
	bysort id: gen round=_n

		gen dv_game=.
		gen tr_game_partner_noncoethnic=0
		gen tr_game_oppositegender=0
	
	forvalues i=1/4{
		replace dv_game= rd`i'_dv if round==`i'
		replace tr_game_partner_noncoethnic=1 if q1!=rd`i'_ethn & round==`i'
		replace tr_game_oppositegender=1 if q2!=rd`i'_gen & round==`i'
		}

		label var tr_game_partner_noncoethnic "Non-coethnic Partner"
		gen interaction=tr_game_partner_noncoethnic*tr_EU_benefits
		label var interaction "Non-coethnic Partner * EU Benefits"
		tsset  id round

	***************
	** Table 2 **
	***************
	** Column 1
	xtreg dv_game tr_game_partner_noncoethnic tr_EU_benefits inter, re
		outreg2 using "REs_Exp2", dec(2) word label se replace ctitle(All)
	** Column 2
	xtreg dv_game tr_game_partner_noncoethnic tr_EU_benefits inter if q1==1, re
		outreg2 using "REs_Exp2", dec(2) word label se append ctitle(Serbians)
	** Column 3
	xtreg dv_game tr_game_partner_noncoethnic tr_EU_benefits inter if q1==2, re
		outreg2 using "REs_Exp2", dec(2) word label se append ctitle(Croatians)
	** Column 4
	xtreg dv_game tr_game_partner_noncoethnic tr_EU_benefits inter if q1==3, re
		outreg2 using "REs_Exp2", dec(2) word label se append ctitle(Croatians)
	

	** Table OA4: Means and standard deviations by groups
	bysort q1: summarize dv_game
	
	** Table OA5, Column 2.  Elected Heterogenous Treatment Effects for Trust Experiment
	xtreg dv_game tr_game_partner_noncoethnic tr_EU_benefits inter##elected, re

	***************
	** Table OA6 **
	***************
	** Column 1
	areg dv_game tr_game_partner_noncoethnic tr_EU_benefits inter, absorb(id)
		outreg2 using "EU_Benefits", dec(2) word label se replace ctitle(All)
	** Column 2
	areg dv_game tr_game_partner_noncoethnic tr_EU_benefits inter if q1==1, absorb(id)
		outreg2 using "EU_Benefits", dec(2) word label se append ctitle(Serbians)
	** Column 3
	areg dv_game tr_game_partner_noncoethnic tr_EU_benefits inter if q1==2, absorb(id)
		outreg2 using "EU_Benefits", dec(2) word label se append ctitle(Croatians)
	** Column 4
	areg dv_game tr_game_partner_noncoethnic tr_EU_benefits inter if q1==3, absorb(id)
		outreg2 using "EU_Benefits", dec(2) word label se append ctitle(Bosniaks)
		
	* Results for first round only
	reg dv_game tr_game_partner_noncoethnic tr_EU_benefits inter if round==1
	reg dv_game tr_game_partner_noncoethnic tr_EU_benefits inter if q1==1 & round==1
	reg dv_game tr_game_partner_noncoethnic tr_EU_benefits inter if q1==2 & round==1
	reg dv_game tr_game_partner_noncoethnic tr_EU_benefits inter if q1==3 & round==1

